﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Security/Security.master" AutoEventWireup="true"
    CodeBehind="UserManagement.aspx.cs" Inherits="_00365.Security.UserManagement" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="server">
    <asp:UpdatePanel ID="updPanel" runat="server">
        <ContentTemplate>
            <asp:Button ID="btnNewUser" runat="server" Text="Novo Usuário" OnClick="btnNewUser_Click" />
            <asp:Panel ID="pnlPopupNewUser" runat="server" CssClass="popUpDialog">
                <div id="divPopupTitle" runat="server" class="popUpDialogTitle head box" style="cursor: move;">
                    <asp:Label ID="lblNewUserDialogTitle" Text="Incluir Novo Usuário" runat="server"
                        Style="cursor: move;" />
                    <div class="alignright">
                        <asp:ImageButton ID="btnCloseNewUser" runat="server" ImageUrl="~/images/popup_close.png"
                            AlternateText="Fechar" OnClick="btnCloseNewUser_Click" ToolTip="Fechar" /></div>
                    <div class="clear">
                    </div>
                </div>
                <div class="clear">
                </div>
                <div class="popUpDialogContent">
                    <div class="content clear">
                        <p>
                            <asp:Label Text="Nome Completo:" runat="server" AssociatedControlID="txtFullName"
                                ID="lblFullName">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Campo 'Nome Completo' é obrigatório."
                                    ControlToValidate="txtFullName" Text="*" ValidationGroup="NewUser" />
                            </asp:Label><asp:TextBox ID="txtFullName" runat="server" CssClass="" ValidationGroup="NewUser"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label Text="Nome de Usuário:" runat="server" AssociatedControlID="txtUsername"
                                ID="lblUserName">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Campo 'Nome de Usuário' é obrigatório."
                                    ControlToValidate="txtUsername" Text="*" ValidationGroup="NewUser" />
                            </asp:Label>
                            <asp:TextBox ID="txtUsername" runat="server" CssClass="" ValidationGroup="NewUser"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label Text="Senha:" runat="server" AssociatedControlID="txtPassword" ID="lblPassword">
                                <asp:RequiredFieldValidator ID="reqValidator" runat="server" ErrorMessage="Campo 'Senha' é obrigatório."
                                    ControlToValidate="txtPassword" Text="*" ValidationGroup="NewUser" />
                            </asp:Label>
                            <asp:TextBox ID="txtPassword" TextMode="Password" runat="server" CssClass="" ValidationGroup="NewUser"></asp:TextBox>
                        </p>
                        <p>
                            <asp:Label Text="Confirme a Senha:" runat="server" AssociatedControlID="txtConfirmPassword"
                                ID="lblConfirmPassword">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Campo 'Confirme a Senha' é obrigatório."
                                ControlToValidate="txtConfirmPassword" Text="*" ValidationGroup="NewUser" />
                                <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Senhas digitadas são diferentes"
                                    ControlToValidate="txtConfirmPassword" ControlToCompare="txtPassword" Text="*" Operator="Equal"
                                    ValidationGroup="NewUser" />
                            </asp:Label>
                            <asp:TextBox ID="txtConfirmPassword" TextMode="Password" runat="server" CssClass=""
                                ValidationGroup="NewUser"></asp:TextBox>
                        </p>
                        <p>
                            Ativo:
                            <asp:RadioButtonList ID="rdlActive" runat="server" ValidationGroup="NewUser">
                                <asp:ListItem Text="Sim" Value="True" Selected="True"></asp:ListItem>
                                <asp:ListItem Text="Não" Value="False"></asp:ListItem>
                            </asp:RadioButtonList>
                        </p>
                        <p>
                            <asp:ValidationSummary runat="server" ValidationGroup="NewUser" />
                        </p>
                    </div>
                    <div class="clear alignright">
                        <asp:Button ID="btnSaveNewUser" runat="server" Text="Salvar" OnClick="btnSaveNewUser_Click"
                            ValidationGroup="NewUser" />
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </asp:Panel>
            <a href="#" id="lnkShowModal" runat="server" style="display: none;">x</a>
            <ajaxToolkit:ModalPopupExtender ID="popAddEditUser" runat="server" BackgroundCssClass="modalBackground"
                CancelControlID="btnCloseNewUser" PopupControlID="pnlPopupNewUser" PopupDragHandleControlID="divPopupTitle"
                TargetControlID="lnkShowModal">
            </ajaxToolkit:ModalPopupExtender>
            <asp:HiddenField ID="hidFlagAddEdit" runat="server" />
            <asp:HiddenField ID="hidUserId" runat="server" />
            <%--Users Grid--%>
            <asp:GridView ID="grdUsers" runat="server" AutoGenerateColumns="False" Width="590px"
                OnRowCommand="grdUsers_RowCommand" ViewStateMode="Enabled" AllowPaging="true"
                OnPageIndexChanged="grdUsers_PageIndexChanged" OnPageIndexChanging="grdUsers_PageIndexChanging"
                PageSize="10">
                <Columns>
                    <asp:BoundField DataField="UserName" HeaderText="Usuário" ReadOnly="True">
                        <ItemStyle Width="140px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="FullName" HeaderText="Nome Completo" ReadOnly="True">
                        <ItemStyle Width="200px" />
                    </asp:BoundField>
                    <asp:CheckBoxField DataField="Active" HeaderText="Ativo" ReadOnly="True">
                        <ItemStyle HorizontalAlign="Center" Width="50px" />
                    </asp:CheckBoxField>
                    <asp:TemplateField HeaderText="Ações">
                        <ItemTemplate>
                            <asp:LinkButton ID="btnEditUser" runat="server" CommandName="EditUser" CommandArgument='<%# DataBinder.Eval (Container.DataItem, "Id") %>'>
                                <asp:Image ID="Image2" ImageUrl="~/images/edit.png" runat="server" AlternateText="Alterar"
                                    ToolTip="Alterar dados do usuário" />
                            </asp:LinkButton>&nbsp;
                            <asp:LinkButton ID="btnRemoveUser" runat="server" CommandName="DeleteUser" CommandArgument='<%# DataBinder.Eval (Container.DataItem, "Id") %>'>
                                <asp:Image ID="Image3" ImageUrl="~/images/delete.png" runat="server" AlternateText="Excluir"
                                    ToolTip="Excluir usuário" />
                            </asp:LinkButton>&nbsp;
                            <asp:LinkButton ID="btnChangePassword" runat="server" CommandName="ChangePassword"
                                CommandArgument='<%# DataBinder.Eval (Container.DataItem, "Id") %>'>
                                <asp:Image ID="Image1" ImageUrl="~/images/password.png" runat="server" AlternateText="Alterar Senha"
                                    ToolTip="Alterar Senha" />
                            </asp:LinkButton></ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="90px" />
                    </asp:TemplateField>
                </Columns>
                <HeaderStyle CssClass="head" />
                <PagerStyle CssClass="head" HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:GridView>
            <%--popup Delete message--%>
            <asp:Panel ID="pnlDeleteMsg" runat="server" CssClass="popUpDialog">
                <div id="divMsgDeleteTitle" runat="server" class="popUpDialogTitle head box" style="cursor: move;">
                    <asp:Label ID="Label1" Text="Excluir Usuário" runat="server" Style="cursor: move;" />
                    <div class="alignright">
                        <asp:ImageButton ID="btnCloseDeleteMsg" runat="server" ImageUrl="~/images/popup_close.png"
                            AlternateText="Fechar" OnClick="btnCloseNewUser_Click" ToolTip="Fechar" /></div>
                    <div class="clear">
                    </div>
                </div>
                <div class="content">
                    <p style="text-align: center;">
                        <asp:Label ID="lblDeleteMsg" runat="server"></asp:Label></p>
                </div>
                <div class="content" style="text-align: center; margin-top: 25px;">
                    <asp:Button ID="btnDeleteMsgYes" runat="server" Text="Sim" OnClick="btnDeleteMsgYes_Click" />
                    &nbsp;
                    <asp:Button ID="btnDeleteMsgNo" runat="server" Text="Não" OnClick="btnDeleteMsgNo_Click" />
                </div>
                <div class="clear">
                </div>
            </asp:Panel>
            <a href="#" id="lnkShowPopupDeleteMsg" runat="server" style="display: none;">x</a>
            <ajaxToolkit:ModalPopupExtender ID="popDeleteMsg" runat="server" BackgroundCssClass="modalBackground"
                CancelControlID="lnkShowPopupDeleteMsg" OkControlID="lnkShowPopupDeleteMsg" PopupControlID="pnlDeleteMsg"
                PopupDragHandleControlID="divMsgDeleteTitle" ViewStateMode="Disabled" TargetControlID="lnkShowPopupDeleteMsg">
            </ajaxToolkit:ModalPopupExtender>
            <%--popup Change password--%>
            <asp:Panel ID="pnlChangePassword" runat="server" CssClass="popUpDialog">
                <div id="divChangePasswordTitle" runat="server" class="popUpDialogTitle head box"
                    style="cursor: move;">
                    <asp:Label ID="Label2" Text="Alterar Senha do Usuário" runat="server" Style="cursor: move;" />
                    <div class="alignright">
                        <asp:ImageButton ID="btnCloseChangePassword" runat="server" ImageUrl="~/images/popup_close.png"
                            AlternateText="Fechar" OnClick="btnCloseNewUser_Click" ToolTip="Fechar" /></div>
                    <div class="clear">
                    </div>
                </div>
                <div class="content">
                    <p>
                        <asp:Label Text="Senha:" runat="server" AssociatedControlID="txtPassword" ID="Label3">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Campo 'Senha' é obrigatório."
                                ControlToValidate="txtChangePassword" Text="*" ValidationGroup="ChangePassword" /></asp:Label>
                        <asp:TextBox ID="txtChangePassword" TextMode="Password" runat="server" CssClass=""
                            ValidationGroup="ChangePassword"></asp:TextBox></p>
                    <p>
                        <asp:Label Text="Confirme a Senha:" runat="server" AssociatedControlID="txtConfirmPassword"
                            ID="Label4">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Campo 'Confirme a Senha' é obrigatório."
                                ControlToValidate="txtChangePasswordConfirm" Text="*" ValidationGroup="ChangePassword" />
                            <asp:CompareValidator ID="CompareValidator2" runat="server" ErrorMessage="Senhas digitadas são diferentes."
                                ControlToValidate="txtChangePasswordConfirm" ControlToCompare="txtChangePassword"
                                Operator="Equal" Text="*" ValidationGroup="ChangePassword" /></asp:Label>
                        <asp:TextBox ID="txtChangePasswordConfirm" TextMode="Password" runat="server" CssClass=""
                            ValidationGroup="ChangePassword"></asp:TextBox></p>
                    <p>
                        <asp:ValidationSummary runat="server" ValidationGroup="ChangePassword" />
                    </p>
                </div>
                <div class="clear alignright" style="margin-top: 25px;">
                    <asp:Button ID="btnChangePassword" runat="server" Text="Salvar" OnClick="btnChangePassword_Click"
                        ValidationGroup="ChangePassword" />
                </div>
                <div class="clear">
                </div>
            </asp:Panel>
            <a href="#" id="lnkShowPopupChangePassword" runat="server" style="display: none;">x</a>
            <ajaxToolkit:ModalPopupExtender ID="popChangePassword" runat="server" BackgroundCssClass="modalBackground"
                CancelControlID="lnkShowPopupChangePassword" OkControlID="lnkShowPopupChangePassword"
                PopupControlID="pnlChangePassword" PopupDragHandleControlID="divChangePasswordTitle"
                ViewStateMode="Disabled" TargetControlID="lnkShowPopupChangePassword">
            </ajaxToolkit:ModalPopupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
